﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RMS.Utils.EventAggregators;

namespace RMS.Utils.RulesManager
{
    public enum EntityState
    {
        Inserting,
        Inserted,
        Updating,
        Updated,
        Deleting,
        Deleted
    }

    public class EntityAction : BaseEvent<EntityActionEventArgs>
    {
        public SubscriptionToken Subscribe<T>(Action<EntityActionEventArgs<T>> action)
        {
            return base.Subscribe(e => action((EntityActionEventArgs<T>)e));
        }
    }
    
    public class EntityActionEventArgs
    {
        public object Entity { set; get; }

        public EntityState State { protected set; get; }
    }
    public class EntityActionEventArgs<TEntity> : EntityActionEventArgs
    {
        public EntityActionEventArgs(EntityState state, TEntity entity)
        {
            base.Entity = entity;
            base.State = state;
        }
        public new TEntity Entity { get { return (TEntity)base.Entity; } }
    }
}
